import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'accountId',
    label: '账号Id',
  },
  {
    component: 'Input',
    fieldName: 'noteId',
    label: '内容Id',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'status',
    label: '软删除',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'runStatus',
    label: '运行状态',
  },
  {
    component: 'Input',
    fieldName: 'taskId',
    label: '任务ID',
  },
  {
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    fieldName: 'publishTime',
    label: '发布时间',
  },
  {
    component: 'Input',
    fieldName: 'screenshotImage',
    label: '屏幕快照',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: 'ID',
    field: 'id',
  },
  {
    title: '账号Id',
    field: 'accountId',
  },
  {
    title: '内容Id',
    field: 'noteId',
  },
  {
    title: '软删除',
    field: 'status',
  },
  {
    title: '运行状态',
    field: 'runStatus',
  },
  {
    title: '任务ID',
    field: 'taskId',
  },
  {
    title: '发布时间',
    field: 'publishTime',
  },
  {
    title: '屏幕快照',
    field: 'screenshotImage',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    label: 'ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '账号Id',
    fieldName: 'accountId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '内容Id',
    fieldName: 'noteId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '软删除',
    fieldName: 'status',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    rules: 'selectRequired',
  },
  {
    label: '运行状态',
    fieldName: 'runStatus',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    rules: 'selectRequired',
  },
  {
    label: '任务ID',
    fieldName: 'taskId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '发布时间',
    fieldName: 'publishTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    rules: 'required',
  },
  {
    label: '屏幕快照',
    fieldName: 'screenshotImage',
    component: 'ImageUpload',
    componentProps: {
      // accept: ['jpg'], // 不支持type/*的写法 支持拓展名(不带.) 文件头(image/png这种)
      // maxNumber: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
      // resultField: 'url', // 上传成功后返回的字段名 默认url 可选['ossId', 'url', 'fileName']
    },
    rules: 'required',
  },
];
